package interview

import (
	"go-interview-forum/model/interview"
	"go-interview-forum/model/user"
)

// InterviewList 面试题列表
func InterviewLists(cateId, userId int64) ([]*interview.Interview, error) {
	answer := user.UserAnswer{UserID: userId, PId: 0}
	all, err := answer.UserAnswerListAll(answer.UserID, answer.PId, 0, 0)
	if err != nil {
		return nil, err
	}

	var ids []int64
	for _, v := range all {
		ids = append(ids, v.InterviewsId)
	}

	listInterview, err := interview.ListInterview(cateId, ids)
	if err != nil {
		return nil, err
	}

	return listInterview, nil
}

// CreateInterview 创建面试题
func CreateInterview(createData interview.Interview) error {
	err := interview.CreateInterview(&createData)
	if err != nil {
		return err
	}

	return nil
}
